import request from '@/utils/request';

/**
 * 获取树
 * @param loadTreeUrl
 * @param level
 * @param pid
 * @param isBaseUrl 兼容低版本url
 * @returns
 */
// eslint-disable-next-line max-params
export function getTreeData(loadTreeUrl, level, pid, isBaseUrl) {
  const baseUrl = isBaseUrl ? `${loadTreeUrl}/get-tree` : loadTreeUrl;
  return request({
    url: `${baseUrl}/${level}/${pid}/v1`,
    method: 'get'
  });
}

/**
 * 树查询
 * @param searchTreeUrl
 * @param params
 * @param isBaseUrl 兼容低版本url
 * @returns
 */
export function searchTree(searchTreeUrl, params, isBaseUrl) {
  const baseUrl = isBaseUrl ? `${searchTreeUrl}/search` : searchTreeUrl;
  return request({
    url: `${baseUrl}/v1`,
    data: params,
    method: 'post'
  });
}
